import { createSlice } from '@reduxjs/toolkit';
import type { TabsState } from '../interface';
import { HOME_URL } from '../../constants';

const tabsState: TabsState = {
    tabsActive: HOME_URL,
    tabsList: [{ label: '首页', key: HOME_URL, closable: false, closeIcon: null }]
}

const tabs = createSlice({
  name: 'tabs',
  initialState: tabsState,
  reducers: {
    setTabsList(state, action) {
      state.tabsList = action.payload;
    },
    setTabsActive(state, action) {
      state.tabsActive = action.payload;
    }
  }
})

const { setTabsList, setTabsActive } = tabs.actions;
export { setTabsList, setTabsActive }
export default tabs.reducer;